package com.xh.bussiness.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xh.bussiness.system.bean.request.AreaRequest;
import com.xh.bussiness.system.service.IAreaService;
import com.xh.core.bean.AjaxResult;
import com.xh.core.constant.AjaxResultConstant;
import com.xh.core.controller.BaseController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author jqm
 */
@Api(tags="地区接口")
@RestController
@RequestMapping("/system/area")
public class AreaController extends BaseController {

	@Autowired
	private IAreaService areaService;

    /**
     * 
     * @return
     */
    @ApiOperation(value="查询所有", notes = "数据来自菁优网")
    @PostMapping("/queryAll")
    public AjaxResult queryAll(){
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS,areaService.queryAll());
    }

    @ApiOperation(value="查询树状结构", notes = "数据字典数据查询-返回所有匹配数据")
    @PostMapping("/queryTree")
    public AjaxResult queryTree(AreaRequest bean){
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS,areaService.queryTree(bean));
    }


    @ApiOperation("根据父节点查询地区数据")
    @RequestMapping("/queryByParentId")
    public AjaxResult queryByParentId(String parentId) {
        return new AjaxResult(AjaxResultConstant.Result.SUCCESS, areaService.queryByParentId(parentId));
    }

}

